package com.baoxin.utils;

import lombok.Data;

import java.io.Serializable;

/**
 * @Author: Rose
 * @Date: 2020/4/24 16:39
 * @version: 1.0.0
 */
@Data
public class Result<T> implements Serializable {

    /**
     * 0表示正常，1表示异常
     */
    private String code;
    /**
     * 面向用户的消息
     */
    private String message;
    /**
     * 面向开发者的详细信息
     */
    private String detail;
    /**
     * 返回给前端的数据
     */
    private T datas;

    public Result(String code, String message, String detail, T datas) {
        this.code = code;
        this.message = message;
        this.detail = detail;
        this.datas = datas;
    }

    public static Result success(String message, String detail) {
        return new Result("0", message, detail, null);
    }

    public static Result fail(String message, String detail) {
        return new Result("1", message, detail, null);
    }
}
